<template>
  <el-dialog v-model="dialogVisible" title="设备管理" top="10vh" width="90%" @close="close">
    <div class="content">
      <div class="item" @click="changeEquipment({name:'摄像头',id:2})">
        <img class="img" src="@/assets/imgs/监控.png" alt="">
        <div class="info">
          <div class="title">监控</div>
          <div class="desc">
            <span class="number" style="color: #91E2F9;">3</span>
            <span class="unit"> 台</span>
          </div>
        </div>
      </div>
      <div class="item" @click="changeEquipment({name: '消防设备',id:3})">
        <img class="img" src="@/assets/imgs/消防设备.png" alt="">
        <div class="info">
          <div class="title">消防设备</div>
          <div class="desc">
            <span class="number" style="color: #91E2F9;">3</span>
            <span class="unit"> 台</span>
          </div>
        </div>
      </div>
      <div class="item" @click="changeEquipment({ name: '道路指示器', id: 1 })">
        <img class="img" src="@/assets/imgs/道路指示器.png" alt="">
        <div class="info">
          <div class="title">道路指示器</div>
          <div class="desc">
            <span class="number" style="color: yellow;">3</span>
            <span class="unit"> 台</span>
          </div>
        </div>
      </div>
    </div>
  </el-dialog>
</template>

<script setup>
const dialogVisible = ref(false)

const activeEquipment = ref('全部')
/** 点击设备 */
const changeEquipment = (item) => {
  const { name, id } = item;
  activeEquipment.value = name;
  window.dispatchEvent(new CustomEvent('changeEquipment', { detail: item }));
}

const open = () => {
  dialogVisible.value = true
}
const close = () => {
  dialogVisible.value = false
}
defineExpose({ open, close })

</script>

<style scoped lang="scss">
.content {
  height: 150px;
  gap: 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;

  .item {
    display: flex;
    gap: 5px;
    align-items: center;

    .img {
      width: 55px;
      height: 55px;
      object-fit: cover;
    }

    .info {
      display: flex;
      flex-direction: column;
      gap: 5px;
      justify-content: center;
      align-items: center;

      .title {
        font-weight: bold;
        font-size: 20px;
      }

      .desc {
        display: flex;
        gap: 5px;
        align-items: center;
        justify-content: center;

        .number {
          font-weight: bold;
          font-size: 20px;
        }

        .info {
          font-size: 14px;
        }
      }

    }
  }
}
</style>